<?php

namespace app\admin\validate\addons;

use tmcore\base\BaseValidate;

class ManageValidate extends BaseValidate
{
    protected $rule = [
        'id' => 'require',
        'file_url' => 'require',
        'name' => 'require',
        'identify' => 'require',
        'version' => 'require',
        'operate_type' => 'require',
        'account' => 'require',
        'password' => 'require',
    ];

    protected $message = [
        'id.require' => '插件id不能为空',
        'file_url.require' => '压缩包不能为空',
        'name.require' => '插件名称不能为空',
        'identify.require' => '插件标识不能为空',
        'version.require' => '插件版本号不能为空',
        'operate_type.require' => '操作类型不能为空',
        'account.require' => '请输入账号',
        'password.require' => '请输入密码',
    ];

    /**
     * 用户登录场景
     * @return ManageValidate
     */
    public function sceneLogin()
    {
        return $this->only(['account','password']);
    }

    /**
     * 商店插件详情场景
     * @return ManageValidate
     */
    public function sceneDetail()
    {
        return $this->only(['identify']);
    }

    /**
     * 本地插件详情场景
     * @return ManageValidate
     */
    public function sceneLocalDetail()
    {
        return $this->only(['id']);
    }

    /**
     * 插件下载场景
     * @return ManageValidate
     */
    public function sceneDownload()
    {
        return $this->only(['identify','version']);
    }

    /**
     * 插件安装场景
     * @return ManageValidate
     */
    public function sceneInstall()
    {
        return $this->only(['identify', 'version']);
    }

    /**
     * 插件卸载场景
     * @return ManageValidate
     */
    public function sceneUninstall()
    {
        return $this->only(['identify']);
    }

    /**
     * 插件更新场景
     * @return ManageValidate
     */
    public function sceneUpdate()
    {
        return $this->only(['identify']);
    }

    /**
     * 插件导入场景
     * @return ManageValidate
     */
    public function sceneImport()
    {
        return $this->only(['file_url', 'name', 'identify', 'version', 'operate_type']);
    }

    /**
     * 依赖场景
     * @return ManageValidate
     */
    public function sceneDepends()
    {
        return $this->only(['identify']);
    }

    /**
     * 命令行场景
     * @return ManageValidate
     */
    public function sceneCommands()
    {
        return $this->only(['operate_type', 'identify']);
    }
}